﻿using System;
using System.Web;
using System.Web.Mvc;
using TidyBlog.MVC;
using TidyBlog.Entity;
using TidyBlog.BLL;

namespace TidyBlog.MVC.WWW.Controllers
{
    /// <summary>
    /// 网站设置控制器 /Manage_Setup/{action}
    /// </summary>
    public class Manage_SetupController : ManageController
    {
        /// <summary>
        /// 编辑网站设置界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit()
        {
            return View(SetupBLL.Read());
        }
        
        /// <summary>
        /// 更新网站设置
        /// </summary>
        /// <param name="setup">网站设置</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Edit(Setup setup)
        {
            SetupBLL.Update(setup);

            RespondentInfo.Success(this.ControllerContext, new OperInfo()
            {
                Message = "已更新网站设置",
                Link = Url.Action("Edit")
            });
            
            return new EmptyResult();
        }
    }
}
